﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ValidationFramework.Reflection;

namespace ValidationFramework
{
    public class ValidationPolicyFactory : IValidationPolicyFactory
	{
		// for performance leverage the cache
		ReflectionCache _reflectionCache;

		internal ValidationPolicyFactory()
		{
			_reflectionCache = new ReflectionCache();
		}
		public ValidationPolicyFactory(ReflectionCache reflectionCache)
		{
			_reflectionCache = reflectionCache;
		}

		public IValidationPolicy CreatePropertyValidationPolicy(PropertyKey key)
		{
			return new ValidationPolicy(_reflectionCache.GetCachedProperty(key));
		}
		public IValidationPolicy CreateFieldValidationPolicy(FieldKey key)
		{
			return new ValidationPolicy(_reflectionCache.GetCachedField(key));
		}
		public IValidationPolicy CreateParameterValidationPolicy(ParameterKey key)
		{
			return new ValidationPolicy(_reflectionCache.GetCachedParameter(key));
		}
	} 

}
